#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> searchRange(vector<int>& nums, int target) {

        int left = 0;
        int right = nums.size() - 1;

        int resleft = 0;
        int resright = 0;

        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (nums[mid] >= target)
            {
                right = mid;
            }
            else
            {
                left = mid + 1;
            }
        }

        if (left == right && nums[left] == target)
        {
            resleft = left;
        }
        else
        {
            return vector(2, -1);
        }

        left = 0;
        right = nums.size() - 1;

        while (left < right)
        {
            int mid = left + (right + 1 - left) / 2;
            if (nums[mid] <= target)
            {
                left = mid;
            }
            else
            {
                right = mid - 1;
            }
        }

        if (left == right && nums[left] == target)
        {
            resright = right;
        }

        return { resleft, resright };

    }
};